package com.google.jacli;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class CommandLine {

    private List<Field> fields = new ArrayList<Field>();
    private Object bean;
    private Pattern pattern;
    private String prefix = CommandLineParser.DEFAULT_PREFIX;
    private String shortPrefix = CommandLineParser.DEFAULT_SHORT_PREFIX;
    private List<Exception> exceptions = new ArrayList<Exception>();

    public CommandLine() {
        setPattern(Pattern.SEQ);
    }
    
    public final Object getBean() {
        return bean;
    }

    public final void setBean(final Object newBean) {
        this.bean = newBean;
    }

    public final List<Field> getFields() {
        return this.fields;
    }

    public void printUsage() {
        printSimpleUsage();
    }
    
    public void printSimpleUsage() {
        printUsage(new DefaultUsage());
    }

    public void printUsage(Usage usage) {
        usage.print(this);
    }

    public final void setPattern(Pattern s) {
        this.pattern = s;
        Pattern.setCommandLine(this);
    }

    public Pattern getPattern() {
        return pattern;
    }

    public String getPrefix() {
        return this.prefix;
    }

    public void setPrefix(String p) {
        this.prefix = p;
    }

    public String getShortPrefix() {
        return this.shortPrefix;
    }

    public void setShortPrefix(String p) {
        this.shortPrefix = p;
    }

    public List<Exception> getExceptions() {
        return this.exceptions;
    }

    public boolean hasException() {
        return this.exceptions.size() > 0;
    }
}